<template>
  <MyCard style="height: 100%" :title="exam.name" back v-if="show">
    <p style="font-weight: bold;padding: 0 0 0 10px">已提交</p>
    <FinishExamUserItem user-commit v-for="(item,index) in gradeList" @clickBtn="toRefereeClick(index)"
                        :grade="item"></FinishExamUserItem>
    <p style="font-weight: bold;padding: 0 0 0 10px;margin-top: 1em">未提交</p>
    <FinishExamUserItem v-for="(item,index) in unCommitList" @clickBtn="toRefereeClick(index)"
                        :grade="item"></FinishExamUserItem>
  </MyCard>
</template>

<script setup lang="ts">
import MyCard from "../../../components/MyCard.vue";
import {Exam, Grade} from "../../../types/mytypes";
import {PageStore} from "../../../store/store";
import {onMounted, reactive, ref} from "vue";
import {ClassRequest, GradeRequest} from "../../../request/MyRequset";
import FinishExamUserItem from "../../../components/FinishExamUserItem.vue";
import router from "../../../router/router";
import {Grape} from "@element-plus/icons-vue";

let show = ref(false)
const exam: Exam = PageStore.getNowExam() as Exam;
//已提交的列表
let gradeList = ref<Grade[]>([])
//未提交的列表
let unCommitList = ref<Grade[]>([])
onMounted(async () => {
  let all = (await GradeRequest.getByExamId(exam.id)).data;
  //根据用户是否已提交划分列表
  for (let i = 0; i < all.length; i++) {
    if (all[i].userCommit) {
      gradeList.value.push(all[i])
    } else {
      unCommitList.value.push(all[i])
    }
  }
  show.value = true;
})
const toRefereeClick = (index: number) => {
  PageStore.setNowGrade(gradeList.value[index]);
  router.push({name: "myExamRefereeDetail"})
}
</script>

<style scoped lang="scss">

</style>